Nested Widgets in Service-now

How to include one widget into another widget.


There are three ways to do that.


1. We can directly include in widget HTML

HTML Body

<widget id="child_widget_name"></widget>



2. Create one variable for widget name in server side and use the data object to show the widget

Server side code:


data.tableWidget = $sp.getWidget("child_widget_name");


HTML Body

 <sp-widget widget="data.tableWidget"></sp-widget>


 

3. We can call the widget in client side script as well


function(spUtil){

var c=this;

spUtil.get(widget_name).then(function (response){

c.myclockwidget=response;


})